package framework;


import java.io.File;

import java.util.ArrayList;




import framework.classification.entities.lattice.TreillisI;

import framework.classification.library.AbstractClassfication;
import framework.classification.library.CompleteClassification;
import framework.classification.library.RPClassification;
import framework.classification.library.SmartClassfication;



public class AnnuaireCocola {


	public static int COMPLETE = 0;
	public static int FAST = 1;
	public static int SMART = 2;

	public static String LATTICE = "LATTICE";
	public static String GSH = "GSH";

	private HierarchyCocola hierarchy;

	private String outputPath;

	private String name;

	private ArrayList<AbstractClassfication> classifications;

	public AnnuaireCocola(String s, String n) {
		name = n;
		hierarchy = new HierarchyCocola(s);
		outputPath = "output/"+name+"/";
		classifications = new ArrayList<AbstractClassfication>();
		initialiseOutputDir();


	}

	public ArrayList<AbstractClassfication> getClassfications(){return classifications;}
	public String getName() {return name;}
	public HierarchyCocola getHierarchy() {return hierarchy;}
	public String getOuputPath(){return outputPath;}

	private void initialiseOutputDir() {
		File file = new File("output/");
		if (!file.exists()) file.mkdir();

		file = new File("output/"+name);
		if (!file.exists()) file.mkdir();
	}


	public void createClassification(){

		AbstractClassfication cl = new CompleteClassification(hierarchy, this,TreillisI.GSH);
		cl.computeClassification();
		classifications.add(cl);

	}
	
	
	public void createClassification(int mode){

		AbstractClassfication cl = null;
		if (mode == COMPLETE){
			cl = new CompleteClassification(hierarchy, this,TreillisI.GSH);
		}
		else if (mode == SMART){
			cl = new SmartClassfication(hierarchy,this,SmartClassfication.NIV2, GSH);

		}
		else if (mode == FAST){
			cl = new RPClassification(hierarchy,this,LATTICE,true);
			
		}
		cl.computeClassification();
		classifications.add(cl);

	}
	
	
	public AbstractClassfication createCompleteClassification(String latticeGeneration){
		AbstractClassfication cl = new CompleteClassification(hierarchy,this,latticeGeneration);
		cl.computeClassification();
		classifications.add(cl);
		return cl;
	}
	
	public AbstractClassfication createSmartClassification(int level,String latticeGeneration){
		AbstractClassfication cl = new SmartClassfication(hierarchy,this,level,latticeGeneration);
		cl.computeClassification();
		return cl;
	}
	
	public AbstractClassfication createFastClassification(Boolean ordered,String LatticeGeneration){
		AbstractClassfication cl = new RPClassification(hierarchy,this,LatticeGeneration,ordered);
		cl.computeClassification();
		return cl;
		
	}
	
	public void createClassification(int mode,String latticeGeneration){

		AbstractClassfication cl = null;
		if (mode == COMPLETE){
			if (latticeGeneration == LATTICE)
				cl = new CompleteClassification(hierarchy,this,TreillisI.LATTICE);
			else if (latticeGeneration == GSH)
				cl = new CompleteClassification(hierarchy,this,TreillisI.GSH);

		}
		else if (mode == SMART){
			if (latticeGeneration == LATTICE)
				cl = new SmartClassfication(hierarchy,this,SmartClassfication.NIV2,LATTICE);
			else if (latticeGeneration == GSH)
				cl = new SmartClassfication(hierarchy,this,SmartClassfication.NIV2, GSH);

		}
		else if (mode == FAST){
			if (latticeGeneration == LATTICE)
				cl = new RPClassification(hierarchy,this,LATTICE,true);
			else if (latticeGeneration == GSH)
				cl = new RPClassification(hierarchy,this, GSH,true);

		}
		cl.computeClassification();
		classifications.add(cl);
	}

	


	



}
